package com.ybb.seckilldemo.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 消息发送者
 */

@Service
@Slf4j
public class MQSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

//    public void send(Object msg) {
//        log.info("发送消息"+msg);
//        rabbitTemplate.convertAndSend("fanoutExchange","",msg);
//    }
//
//    public void sendByDirectred(Object msg) {
//        log.info("发送red消息"+msg);
//        rabbitTemplate.convertAndSend("dirctExchange","queue.red",msg);
//    }
//
//    public void sendByDirectgreen(Object msg) {
//        log.info("发送green消息"+msg);
//        rabbitTemplate.convertAndSend("dirctExchange","queue.green",msg);
//    }

    /**
     * 秒杀模块  发送秒杀信息
     */
    public void sendSeckillMessage(String message) {
        log.info("发送消息：" + message);
        rabbitTemplate.convertAndSend("seckillExchange","seckill.message",message);
    }

}
